.user_new
  = form_for [:admin, @user] do |f|
    -if @user.errors.any?
      #error_explanation
        %ul.unstyled.alert.alert-error
          - @user.errors.full_messages.each do |msg|
            %li= msg

    %fieldset
      %legend 账号
      .control-group
        = f.label :name
        .controls
          = f.text_field :name, required: true, autocomplete: "off"
          %span.help-inline * 必需
      .control-group
        = f.label :username
        .controls
          = f.text_field :username, required: true, autocomplete: "off"
          %span.help-inline * 必需
      .control-group
        = f.label :email
        .controls
          = f.text_field :email, required: true, autocomplete: "off"
          %span.help-inline * 必需

    - if @user.new_record?
      %fieldset
        %legend 密码
        .control-group
          = f.label :password
          .controls
            %strong
              这是一个临时密码,
              %br
              将在用户第一次登录后需要修改.
    - else
      %fieldset
        %legend 密码
        .control-group
          = f.label :password
          .controls= f.password_field :password, disabled: f.object.force_random_password
        .control-group
          = f.label :password_confirmation
          .controls= f.password_field :password_confirmation, disabled: f.object.force_random_password

    %fieldset
      %legend 权限
      .row
        .span8
          .control-group
            = f.label :projects_limit
            .controls= f.number_field :projects_limit

          .control-group
            = f.label :can_create_group
            .controls= f.check_box :can_create_group

          .control-group
            = f.label :admin do
              %strong.cred 管理员
            .controls= f.check_box :admin
        .span4
          - unless @user.new_record?
            .alert.alert-error
              - if @user.blocked?
                %p 该已被禁用, 无法登录 GitLab
                = link_to '解禁', unblock_admin_user_path(@user), method: :put, class: "btn btn-small"
              - else
                %p 被禁用的用户, 其所有项目将被删除 &amp; 并且无法登录 GitLab.
                = link_to '禁用', block_admin_user_path(@user), confirm: '你确定要禁用此用户吗?', method: :put, class: "btn btn-small btn-remove"
    %fieldset
      %legend Profile
      .control-group
        = f.label :skype
        .controls= f.text_field :skype
      .control-group
        = f.label :linkedin
        .controls= f.text_field :linkedin
      .control-group
        = f.label :twitter
        .controls= f.text_field :twitter

    .form-actions
      - if @user.new_record?
        = f.submit '创建用户', class: "btn btn-create"
        = link_to '取消', admin_users_path, class: "btn btn-cancel"
      - else
        = f.submit '保存更改', class: "btn btn-save"
        = link_to '取消', admin_user_path(@user), class: "btn btn-cancel"
